var regInt = /^([1-9]{1}\d{0,})$/;
var regFloat = /^(\d+)(\.?)(\d{0,4})$/;

/**
 * 产品名称输入框获取焦点，设置输入框校验显示信息列的样式
 */
function productNameFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "产品名称，必填，最长64个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 产品名称输入框失去焦点时的校验
 */
function productNameBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "产品名称不能为空";
    } else if(objValue.length > 64 ) {
        errMsg = "产品名称最大长度为64个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 公司名称输入框获取焦点，设置输入框校验显示信息列的样式
 */
function companyNameFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "公司名称，必填，最长16个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 公司名称输入框失去焦点时的校验
 */
function companyNameBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "公司名称不能为空";
    } else if(objValue.length > 16 ) {
        errMsg = "公司名称最大长度为16个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 所属分类 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function insuranceTypeFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "所属分类，最长16个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 所属分类输入框失去焦点时的校验
 */
function insuranceTypeBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue != "" && objValue.length > 16 ) {
        errMsg = "所属分类最大长度为16个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 保费 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function premiumFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "保费，必填，最长16个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 保费输入框失去焦点时的校验
 */
function premiumBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "保费不能为空";
    } else if(objValue.length > 16 ) {
        errMsg = "保费最大长度为16个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 保障期限输入框获取焦点，设置输入框校验显示信息列的样式
 */
function timeLimitFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "保障期限，必填，最长16个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 保障期限输入框失去焦点时的校验
 */
function timeLimitBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "保障期限不能为空";
    } else if(objValue.length > 16 ) {
        errMsg = "保障期限最大长度为16个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}


/**
 * 表单提交
 */
function addInsurProductFun() {
	// 校验产品名称
	var productNameObj = document.getElementById("productName");
	if(!productNameBlur(productNameObj, 'productNameCol', 'productNameDesc')) {
		return false;
	}
	
	// 校验 公司名称
	var companyNameObj = document.getElementById("companyName");
	if(!companyNameBlur(companyNameObj, 'companyNameCol', 'companyNameDesc')) {
		return false;
	}
	
	// 所属分类
	var insuranceTypeObj = document.getElementById("insuranceType");
	if(!insuranceTypeBlur(insuranceTypeObj, 'insuranceTypeCol', 'insuranceTypeDesc')) {
		return false;
	}
	
	// 保费
	var premiumObj = document.getElementById("premium");
	if(!premiumBlur(premiumObj, 'premiumCol', 'premiumDesc')) {
		return false;
	}
	
	// 保障期限
	var timeLimitObj = document.getElementById("timeLimit");
	if(!timeLimitBlur(timeLimitObj, 'timeLimitCol', 'timeLimitDesc')) {
		return false;
	}
	
	document.getElementById("productInsurForm").submit();
    return true;
}

